package com.neu.admin;

import com.neu.common.validator.Order;
import com.neu.common.validator.Sort;
import com.neu.domain.ShoppingCollect;
import com.neu.service.ShoppingCollectService;
import com.neu.util.response.BaseResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 用户管理
 * 杨帆
 */
@RestController
@RequestMapping("/admin/collect")
public class AdminCollectController {
    @Autowired
    private ShoppingCollectService shoppingCollectService;

    @GetMapping("/list")
    public ResponseEntity<BaseResponse<ShoppingCollect>> list(Integer userId, Integer valueId,
                                                              @RequestParam(defaultValue = "10") String pageSize,

                                                              @RequestParam(defaultValue = "1") String pageNum,

                                                              @Sort @RequestParam(defaultValue = "add_time") String sort,

                                                              @Order @RequestParam(defaultValue = "desc") String order) {

        try {
            List<ShoppingCollect> collectList = shoppingCollectService.querySelective(pageSize,pageNum,userId,valueId,sort,order);
            if (collectList != null){
                return BaseResponse.generateOKListResponseEntity(collectList);
            }
            return BaseResponse.generateBadResponseEntity(500,"查询信息不存在","");
        }catch (Exception e){
            e.printStackTrace();
            return BaseResponse.generateBadResponseEntity(500,"系统异常","");
        }




    }
}
